<script>
    $(function(){
        PageAction.currentPageActionClassName = '<?= $_GET['currentPageActionClassName'] ?>';
        PageAction.currentPageAction = '<?= ucfirst($_GET['action']) ?>';

        if (typeof PageAction[PageAction.currentPageActionClassName].doContentAction == 'undefined') {
            PageAction[PageAction.currentPageActionClassName].doContentAction = function() {
                var _test = Tools.checkNull('title', '请输入信息标题');
                if (_test) {
                    $.dialog.locking('系统已启动，请稍候。。。');

                    PageAction.editor.sync();

                    var _this = this;
                    $.post(this.handlerUrl + PageAction.currentPageAction,
                        Tools.addEditPageLoader().DOM.form.serializeArray(),
                        function(data) {
                            switch (data.status) {
                                case 'SUCCESS' :
                                    $(_this.grid).dataGridReload();

                                    $.dialog.locking.confirm('success', '编辑成功，您还需要继续添加吗？', function(){

                                        Tools.addEditPageLoader()
                                            .resetConfig({
                                                content : 'load:' + _this.addEditPage + '&action=add'
                                                + '&parentId=' + $('#category_id').val()
                                            }, true);

                                        return true;
                                    }, function(){
                                        Tools.addEditPageLoader().close();
                                        return true;
                                    });

                                    break;
                                case 'NO_CHANGES' :
                                    $.dialog.locking.alert('ndash', data.desc);
                                    break;
                                case 'DB_ERROR' :
                                case 'INTERCEPTOR' :
                                case 'SEO_URL_IS_EXISTS' :
                                    $.dialog.locking.alert('error', data.desc);
                                    break;
                                default :
                                    $.dialog.locking.alert('error', '系统繁忙，请稍候再试');
                                    break;
                            }
                        }, 'json');
                }
            };
        }

        Tools.addEditPageLoader()
            .title('<?= $this->adminMap[$this->security]['title'] ?> » <?= $this->adminMap[$this->security]['menu'][$_GET['parentPageId']]['name'] ?> » <?= App\Admin\Helper::getActionName($_GET['action']) ?>');

        <?php
        if ($this->pageControl) {
        ?>
        Tools.addEditPageLoader().button({
            id : 'ok',
            name : Tools.addEditPageLoader().config.okVal,
            callback : function(){

                PageAction[PageAction.currentPageActionClassName]
                    .doContentAction
                    .call(PageAction[PageAction.currentPageActionClassName]);

                return false;
            },
            unshift : true,
            type : 'submit',
            focus: true
        });
        <?php
        }
        ?>
        Tools.switchDiv('.switch > ul > li', 'slt_switch', '.switch_list');

        $('.tags > ol > li > span').click(function(){
            var _archivesTags = $('#archives_tags').val();
            var _tag = $(this).text();

            if (_archivesTags.indexOf(_tag) == -1) {
                if (_archivesTags.trim().length > 0) {
                    _archivesTags += ',';
                }
                _archivesTags += _tag;
            }
            $('#archives_tags').val(_archivesTags);
        });
    });
</script>

<input type="hidden" name="id" id="id" value="<?= $_GET['id'] ?>">
<div class="switch">
    <ul>
        <li class="slt_switch">基本信息</li>
    </ul>
    <div class="switch_list">
        <table width="100%" cellpadding="0" cellspacing="0" class="data_input">
            <tr>
                <th>标题</th>
                <td><?= App\Tools\Html::text($this->pageControl, 'title', $this->rs) ?></td>
            </tr>
            <tr>
                <th>排序<br/>(数值越大越靠前)</th>
                <td><?= App\Tools\Html::text($this->pageControl, 'sort', $this->rs ? $this->rs : $this->getSort) ?></td>
            </tr>
            <tr>
                <th>相关图
                    <br />
                    (缩略图)
                    <br/>建议尺寸:
                    <br/>(846*751)
                </th>
                <td><?= App\Admin\Helper::createUpFile('img', 'cover', $this->rs ? $this->rs->cover : null,
                        $this->setting['aryPicExtName'], $this->setting['aryFileExtName'], $this->__CDN__, $this->__ASSETS__) ?></td>
            </tr>
        </table>
    </div>
</div>